package EventManager;

import java.io.IOException;
import java.util.LinkedList;

public class Listener
{
	private String m_name;
	private LinkedList<EventType> m_eventMonitor;

	/**
	 * Default Constructor
	 */
	public Listener()
	{
		m_eventMonitor = new LinkedList<EventType>();
	}
	/**
	 * Adds an event to be watch
	 */
	public void addEventMonitor(EventType event)
	{
		m_eventMonitor.addFirst(event);
	}
	/**
	 * Processes the events
	 * 
	 * @return true if event handled, false otherwise
	 * @throws IOException 
	 */
	public boolean HandleEvent(EventType event) throws IOException
	{
		return false;
	}
	/**
	 * Deletes an event from being watched
	 * @return true if event deleted, false otherwise
	 */
	public boolean deleteEventMonitor(EventType event)
	{
		if (m_eventMonitor.contains(event))
		{
			m_eventMonitor.remove(event);
			return true;
		} else
		{
			return false;
		}
	}
	/**
	 * Deletes an event from being watched based on string eventName
	 * @return true if event deleted, false otherwise
	 */
	public boolean deleteEventMonitor(String eventName)
	{
		for (EventType e : m_eventMonitor)
		{
			if (e.getName().equals(eventName))
			{
				m_eventMonitor.remove(e);
				return true;
			}
		}
		return false;
	}
	/**
	 * Searches m_eventMonitor for specified event
	 * 
	 * @return true if event exists, false otherwise
	 */
	public boolean SearchEventMonitor(EventType event)
	{
		return m_eventMonitor.contains(event);
	}
	/**
	 * Gets m_name, the name of the Listener
	 */
	public String getName()
	{
		return m_name;
	}
	/**
	 * Sets the name of the Listener (m_name)
	 */
	public void setName(String name)
	{
		m_name = name;
	}
}
